<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript" src="js/jquery.min.js"></script>
<html>
<head>
	<title>竞赛参与</title>
	<meta name="decorator" content="default"/>

	<script type="text/javascript">



		window.onload = myfun;
		var time = 0;
		function myfun()
		{
			$("#btnMenu").hide();
			time = document.getElementById("time").value;
			aa();
		}

		function aa() {
			var intDiff = parseInt(time);//倒计时总秒数量
			function timer(intDiff) {
				window.setInterval(function () {
					var day = 0,
							hour = 0,
							minute = 0,
							second = 0;//时间默认值
					if (intDiff > 0) {
						day = Math.floor(intDiff / (60 * 60 * 24));
						hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
						minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
						second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
					}
					if (minute <= 9) minute = '0' + minute;
					if (second <= 9) second = '0' + second;
					$('#day_show').html(day + "天");
					$('#hour_show').html('<s id="h"></s>' + hour + '时');
					$('#minute_show').html('<s></s>' + minute + '分');
					$('#second_show').html('<s></s>' + second + '秒');
					intDiff--;
					if(intDiff == 0){
						var  size = document.getElementById("size").value;
						for(var  i = 0; i < size; i++){
							document.getElementById("a-"+i).onclick = function(){};
						}
						haha();
					}
				}, 1000);
			}
			$(function () {
				timer(intDiff);
			});
		}
      function haha(){
		  alert("比赛时间结束");
	  }

		//-------------------------



           var  subjectId = "";
			var score = "";
		var ctfSubjectTypeId = "";
		var ctfSubjectName = "";
		var link = "";
	  function 	answer(id,ctfSubjectTypeList){
		  console.info(id);
		  $.ajax({
			  type: "POST",
			  url: "${ctxf}/race/raceLogin/answer",
			  data: {
				  id:id
			  },
			  success: function (Class) {
				  if(Class.score != null)
				     score = Class.score;
				  if(Class.ctfSubjectTypeId != null)
				  ctfSubjectTypeId = Class.ctfSubjectTypeId;
				  if(Class.ctfSubjectName != null)
				  ctfSubjectName = Class.ctfSubjectName;
				  if(Class.link != null)
				  link = Class.link;

				  if(Class.id != null)
					  subjectId = Class.id;

				  answer1();
			  },
			  error:function(){
				  console.info("error");
			  }
		  });
	  }
		function answer1(){
			 console.info();
			 $.ajax({
				 type: "POST",
				 url: "${ctxf}/race/raceLogin/answer1",
				 data: {
						 id : ctfSubjectTypeId
				 },
				 success: function (Class) {
					 if(Class.id == ctfSubjectTypeId){
						 ctfSubjectTypeId = Class.subjectTypeName;
					 }
					 answer2();
				 },
				 error:function(){
					 console.info("error");
				 }
			 });
		 }
		function answer2(){
			document.getElementById('label1').innerHTML = score;
			document.getElementById('label2').innerHTML = ctfSubjectTypeId;
			document.getElementById('label3').innerHTML = ctfSubjectName;
			document.getElementById('label4').innerHTML = link;
			document.getElementById("label5").value=subjectId;
			$.jBox($("#importBox").html(), {
				title:false,
				buttons: false
			})
		}
	</script>
</head>
<body>

<div id="importBox" class="hide">
	<form id="importForm" action="${ctxf}/race/raceLogin/flag" method="post" enctype="multipart/form-data"
		  class="form-search" style="padding-left:20px;"><br/>
		<input name="repertoryId" value="${rid}" type="hidden">
		<input type="hidden" value="${raceSchedule.id}" name="scheduleId">
		<input name="usetID" type="hidden" value="${userId}">
		<input id="label5" name="subjectId" type="hidden" value="">
		分值：<label id="label1"></label>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       类型： <label id="label2"></label><br/><br/>
		题目：<label id="label3"></label>   <br/><br/>
		解题链接：<a id="label4"></a> <br/><br/>
		<div>
			Flag:<input  name="flag" type="text"/>
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value=" 提交 "/>
		</div>
	</form>
</div>






<ul class="nav nav-tabs">
	<li class="active"><a>答题情况</a></li>
</ul>


<form:form id="searchForm" modelAttribute="RaceCtfSubject" action="${ctxf}/race/raceLogin/fuzzyQuery" method="delete" class="breadcrumb form-search">
	<input type="hidden" value="${raceSchedule.id}" name="scheduleId">
	<input name="usetID" type="hidden" value="${userId}">

	<input type="hidden" value="${judge}" name="judge" id="judge">
	<%--<input type="hidden" value="${user}" name="user" id="user">--%>
	<%--<input type="hidden" value="${paw}" name="paw" id="paw">--%>
	<input type="hidden" value="${repertoryId}" name="repertoryId" id="repertoryId">
	<input type="hidden" value="${scheduleId}" name="scheduleId" id="scheduleId">
	<input type="hidden" value="${raceCtfSubject.id}" name="subjectId" id="subjectId">


	<ul class="ul-form">
		<li style="margin-right: 60px"><label>题目总数：</label>
				${size}
			<input id="size" type="hidden" value="${size}">
		</li>
		<li ><label>已解答总数：</label>
			${answeris}
		</li>
		<li style="margin-right: 10px"><label>总分：</label>
			${score}

		</li>
		<li style="margin-right: 40px"><label>得分：</label>
			${scores}
		</li>
		<li>

			<input id="time" type="hidden" value="${time}">
			<label style="width: 100px">倒计时:</label>
			  <span>
				  <strong id="day_show">0天</strong>
				  <strong id="hour_show">0时</strong>
		          <strong id="minute_show">0分</strong>
		          <strong id="second_show">0秒</strong>
			  </span>
		</li>

		<li style="margin-right: 40px"><label>比赛公告：</label>
			${raceSchedule.scheduleNotice}
		</li>

</ul>
		<ul class="ul-form">
          <input name="repertoryId" value="${rid}" type="hidden">
			<li><label>题目名称：</label>
				<input name="ctfSubjectName" type="text" htmlEscape="false" maxlength="64" class="input-medium">
			</li>
		<li><label>标签：</label>
			<input name="label" type="text" htmlEscape="false" maxlength="64" class="input-medium">
		</li>

		<li><label>类型：</label>
			<select name="type" class="input-medium">
				<option></option>
				<c:forEach items="${ctfSubjectTypeList}" var="ctfSubjectType">
				<option>${ctfSubjectType.subjectTypeName}</option>
				</c:forEach>
			</select>
		</li>
			<li>
				<label>难度：</label>
				<select name="difficulty"  class="input-medium">
					<option></option>
					<c:forEach var="difficulty" varStatus="st" items="${fns:getDictList('resource_question_difficulty')}">
						<option value="${st.index}"> ${difficulty}</option>
					</c:forEach>
				</select>
			</li>

		<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>

			<li class="btns"><div style="width: 50px"></div></li>

			<li class="btns"><a style="color: red" target="view_window" href="${ctxf}/race/present"> 竞赛呈现页面 </a></li>
			<li class="btns"><div style="width: 50px"></div></li>
			<li class="btns"> <a href="${ctxf}/race/raceLogin"  style="float:left " class="btn btn-primary" >返回登录页面</a> </li>


		<li class="clearfix"></li>
	</ul>
</form:form>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<thead>
	<tr>
		<th>题目名称</th>
		<th>难度值</th>
		<th>标签</th>
		<th>类型</th>
		<th>分值</th>
		<th>解答情况</th>
		<th>答 案</th>
	</tr>
	</thead>
	<tbody>
	<c:forEach items="${raceCtfSubjects}" var="raceCtfSubject" varStatus="in">
		<tr>
			<td>

					<%--<c:if test="${raceScheduleTeamSubject1.answeris == null }"><a onclick="answer('${raceCtfSubject.id}','${ctfSubjectTypeList}')"> ${raceCtfSubject.ctfSubjectName} </a></c:if>--%>


				<c:forEach items="${raceScheduleTeamSubjects1}" var="raceScheduleTeamSubject" varStatus="in">
					<c:if test="${raceScheduleTeamSubject.subjectid == raceCtfSubject.id}">
						<c:if test="${raceScheduleTeamSubject.answeris == '0' }">
							<%--<a href="${ctx}/resource/resourceCtfSubject/raceEnterCtfSubjectForm?CtfSubjectId=${raceCtfSubject.id}&userId=${userId}&judge=${judge}&user=${user}&paw=${paw}&repertoryId=${repertoryId}&scheduleId=${scheduleId}&subjectId=${raceCtfSubject.id}">${raceCtfSubject.ctfSubjectName} </a>--%>
							<%--<a href="${ctxf}/race/raceLogin/raceEnterCtfSubjectForm?CtfSubjectId=${raceCtfSubject.id}&userId=${userId}&judge=${judge}&user=${user}&paw=${paw}&repertoryId=${repertoryId}&scheduleId=${scheduleId}&subjectId=${raceCtfSubject.id}">${raceCtfSubject.ctfSubjectName} </a>--%>
							<a href="${ctxf}/race/raceLogin/raceEnterCtfSubjectForm?CtfSubjectId=${raceCtfSubject.id}&userId=${userId}&judge=${judge}&repertoryId=${repertoryId}&scheduleId=${scheduleId}&subjectId=${raceCtfSubject.id}">${raceCtfSubject.ctfSubjectName} </a>

							<%--<a id="a-${in.index}" onclick="answer('${raceCtfSubject.id}','${ctfSubjectTypeList}')"> ${raceCtfSubject.ctfSubjectName}</a>--%>
						</c:if>
						<c:if test="${raceScheduleTeamSubject.answeris == '1'}">${raceCtfSubject.ctfSubjectName}</c:if>
					</c:if>
				</c:forEach>






			</td>
			<td>${fns:getDictLabel(raceCtfSubject.difficulty, 'resource_question_difficulty', '')}</td>
			<td>${raceCtfSubject.label}</td>
			<td><c:forEach items="${ctfSubjectTypeList}" var="ctfSubjectType"><c:if test="${ctfSubjectType.id==raceCtfSubject.type}">${ctfSubjectType.subjectTypeName}</c:if></c:forEach></td>
			<td>${raceCtfSubject.score}</td>
			<td>

				<c:forEach items="${raceScheduleTeamSubjects1}" var="raceScheduleTeamSubject">

					<c:if test="${raceScheduleTeamSubject.subjectid == raceCtfSubject.id}">
						<c:if test="${raceScheduleTeamSubject.answeris == '0'}">未解答</c:if>
						<c:if test="${raceScheduleTeamSubject.answeris == '1'}">已解答</c:if>
					</c:if>
				</c:forEach>
			</td>
			<td>


				<c:forEach items="${raceScheduleTeamSubjects1}" var="raceScheduleTeamSubject">

					<c:if test="${raceScheduleTeamSubject.subjectid == raceCtfSubject.id}">
						<c:if test="${raceScheduleTeamSubject.rightandwrong == '0'}">  </c:if>
						<c:if test="${raceScheduleTeamSubject.rightandwrong == '1'}">正确</c:if>
						<c:if test="${raceScheduleTeamSubject.rightandwrong == '2'}">错误</c:if>
					</c:if>
				</c:forEach>




			</td>
		</tr>
	</c:forEach>
	</tbody>
</table>
<div class="pagination">${page}</div>

<%--<a href="${ctxf}/race/raceLogin/test">111111111111</a>--%>
</body>
</html>